package org.mebusw.struts.davincicode;

import junit.framework.TestCase;
import junit.framework.Assert;

public class TestCardHand extends TestCase {

	private CardHand op = null;

	public TestCardHand(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
		op = new CardHand();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testInsertSort_black_numbercard_1() {
		op.clear();
		op.insertSort(new DavinciCard(true, 3, false, -1));
		op.insertSort(new DavinciCard(false, 5, false, -1));

		op.insertSort(new DavinciCard(true, 5, false, 0));
		Assert.assertEquals(3, op.size());
		// Assert.assertEquals("target", op.get(1).getCardId());
	}

	public void testInsertSort_black_numbercard_2() {
		op.clear();
		op.insertSort(new DavinciCard(true, 3, false, -1));
		op.insertSort(new DavinciCard(false, 6, false, -1));

		op.insertSort(new DavinciCard(true, 5, false, 0));
		Assert.assertEquals(3, op.size());
		// Assert.assertEquals("target", op.get(1).getCardId());
	}

	public void testValidatePos_wo_joker_1() {
		op.clear();
		op.add(new DavinciCard(true, 3, false, 3));
		op.add(new DavinciCard(true, 4, false, 4));

		boolean result = op.validatePos(new DavinciCard(false, 3, false,
				13), 1);
		Assert.assertEquals(true, result);
	}

	public void testValidatePos_wo_joker_2() {
		op.clear();
		op.add(new DavinciCard(false, 3, false, 13));
		op.add(new DavinciCard(true, 4, false, 4));

		boolean result = op.validatePos(new DavinciCard(false, 3, false,
				3), 1);
		Assert.assertEquals(false, result);
	}

	public void testValidatePos_w_joker_1() {
		op.clear();
		op.add(new DavinciCard(true, 3, false, 3));
		op.add(new DavinciCard(true, -1, true, 9));
		op.add(new DavinciCard(false, -1, true, 19));
		op.add(new DavinciCard(true, 4, false, 4));

		boolean result = op.validatePos(new DavinciCard(false, 3, false,
				13), 2);
		Assert.assertEquals(true, result);
	}

	public void testValidatePos_w_joker_2() {
		op.clear();
		op.add(new DavinciCard(true, 3, false, 3));
		op.add(new DavinciCard(true, -1, true, 9));
		op.add(new DavinciCard(false, -1, true, 19));
		op.add(new DavinciCard(true, 4, false, 4));

		boolean result = op.validatePos(new DavinciCard(false, 3, false,
				13), 3);
		Assert.assertEquals(true, result);
	}

	public void testValidatePos_w_joker_3() {
		op.clear();
		op.add(new DavinciCard(true, -1, true, 9));
		op.add(new DavinciCard(false, -1, true, 19));

		boolean result = op.validatePos(new DavinciCard(false, 3, false,
				13), 1);
		Assert.assertEquals(true, result);
	}

	public void testValidatePos_w_joker_4() {
		op.clear();
		op.add(new DavinciCard(true, -1, true, 9));
		op.add(new DavinciCard(false, -1, true, 19));

		boolean result = op.validatePos(new DavinciCard(false, 3, false,
				13), 0);
		Assert.assertEquals(true, result);
	}

}
